package cn.com.nes.site.entity.em.crm.clue;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 线索入池方式
 *  值域对应 t_param 表 param_type=12
 */
public enum CluePoolEntryEnum {

    AUTO_FALLING_INTO("01", "自动落入"),
    RETURN("02", "退回"),
    RECOVERY("03", "回收"),
    IMPORT("04", "导入"),
    ENTER("05", "录入"),

    ;

    private String key;

    private String value;

    CluePoolEntryEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static CluePoolEntryEnum getEnum(String key) {
        Map<String, CluePoolEntryEnum> map = new HashMap<>();
        for (CluePoolEntryEnum cluePoolEntryEnum : values()) {
            map.put(cluePoolEntryEnum.getKey(), cluePoolEntryEnum);
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的线索入池方式");
        }
        return map.get(String.valueOf(key));
    }
}
